package com.wang.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @Classname Knif4jConfig
 * @Description TODO
 * @Date 2025/3/21 15:03
 * @Created by pc
 */
// @EnableSwagger2WebMvc
// // @EnableKnife4j
// @Configuration
// @EnableWebMvc
public class Knif4jConfig {
    @Bean
    public Docket apiDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.wang.controller.api"))
                //.paths(PathSelectors.any())
                .build().apiInfo(apiInfo())
                .groupName("前台接口");
    }

    @Bean
    public Docket adminDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.wang.controller.admin"))
                //.paths(PathSelectors.any())
                .build().apiInfo(apiInfo())
                .groupName("后台接口");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("66项目接口文档")
                .description("66班电商项目接口测试文档")
                .version("0.0.1")
                .contact(new Contact("wang", "https://www.baidu.com", "110@qq.com"))
                .termsOfServiceUrl("https://www.baidu.com")
                .license("")
                .build();
    }


}
